/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
 * Description:
 * Author: g00421808
 * Create: 6/24/2022
 * Notes:
 */

#ifndef JSBIND_BINDING_H
#define JSBIND_BINDING_H

#include <forward_list>
#include <unordered_map>
#include <memory>

#include "jsbind/invoker/invoker.h"
#include "jsbind/function.h"
#include "jsbind/class/class.h"
#include "jsbind/config.h"
#include "jsbind/value/napi/js_function.h"

#if JSBIND_SUPPORT_DECLARATION
#include "jsbind/reflect/type_meta.h"
#endif

namespace Jsb {

class JSBIND_EXPORT Binding {
public:
    static std::forward_list<Function>& GetFunctionList();

    static void RegisterFunction(const char *name, int32_t invokerId, Binder* binder);

    static std::forward_list<ClassBase*>& GetClassList();

    static void RegisterClass(ClassBase* xlass);

    static std::unordered_map<std::string, std::unique_ptr<JSFunction>>& GetJSFunctionMap();

    static int RegisterJSFunction(const std::string& name, std::unique_ptr<JSFunction> func);

#if JSBIND_SUPPORT_DECLARATION
    static std::forward_list<const TypeMeta*>& GetBuildInTypeList();
#endif

    static bool SupportAsyncWork() {
#if JSBIND_ASYNC_WORK
        return true;
#else
        return false;
#endif
    }

private:
    Binding() = delete;

    Binding(const Binding&) = delete;
};
} // namespace Jsb

#endif //JSBIND_BINDING_H
